import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:winkai/entity/role_info.dart';
import 'package:winkai/entity/subscribe_from.dart';
import 'package:winkai/helper/iap/iap_helper.dart';
import 'package:winkai/res/app_colors.dart';
import 'package:winkai/res/dimens.dart';
import 'package:winkai/utils/image_utils.dart';
import 'package:winkai/utils/page_jump_utils.dart';

class UserDetailsTitleBar extends StatefulWidget {
  const UserDetailsTitleBar({super.key});

  @override
  State<UserDetailsTitleBar> createState() => _UserDetailsTitleBarState();
}

class _UserDetailsTitleBarState extends State<UserDetailsTitleBar> {
  @override
  Widget build(BuildContext context) {
    return SafeArea(
      left: false,
      bottom: false,
      right: false,
      child: Container(
        height: 48.w,
        padding: EdgeInsets.symmetric(horizontal: Dimens.mainHorizontalSpacing),
        child: Row(
          children: [
            GestureDetector(
              onTap: () {
                Get.back();
              },
              child: ImageUtils.getImage('ic_ai_back', 36.w, 36.w),
            ),
            const Expanded(child: SizedBox()),
            Obx(() {
              IAPHelper().subscribeStatus.value;
              var isSubscribeVip = IAPHelper().isVip;
              return isSubscribeVip
                  ? SizedBox(
                      width: 36.w,
                      height: 36.w,
                    )
                  : GestureDetector(
                      onTap: () {
                        PageJumpUtils.toVipPage(SubscribeFrom.userVip);
                      },
                      child: ImageUtils.getImage('ic_ai_root_vip', 36.w, 36.w),
                    );
            })
          ],
        ),
      ),
    );
  }
}
